package SortMethod;

import SortHelper.SortHelper;

public class InsertSort {

    private InsertSort(){}

    public static <E extends Comparable<E>> void sort(E[] arr){
        if (arr.length > 1) {
            for (int i = 1; i < arr.length; i++)
                for (int j = i; j > 0 && arr[j].compareTo(arr[j-1]) < 0; j--)
                        SortHelper.swap(arr,j,j-1);
        }else {
            return;
        }
    }
}
